import 'package:ddframework/state_manager/state_manager.dart';
import 'package:flutter/material.dart';

class Global {
  /// 底部安全距離
  static double _bottomHeignt = 0;
  static double get bottomHeignt {
    return _bottomHeignt;
  }

  static double _statusBarHeight = 0;

  /// 状态栏高度
  static double get statusBarHeight {
    return _statusBarHeight;
  }

  static double _screenWidth = 0;
  static double get screenWidth {
    return _screenWidth;
  }

  static double _screenHeight = 0;
  static double get screenHeight {
    return _screenHeight;
  }

  static late BuildContext rootContext;
  static updateRootContext(BuildContext context) {
    rootContext = context;
    _statusBarHeight = MediaQuery.of(context).padding.top;
    _bottomHeignt = MediaQuery.of(context).padding.bottom;
    _screenWidth = MediaQuery.of(context).size.width;
    _screenHeight = MediaQuery.of(context).size.height;
    print("设置更新rootContext");
  }

  static late DDStore _store;
  static DDStoreAgent? _storeAgent;
  static DDStoreAgent get storeAgent {
    if (_storeAgent != null) {
      return _storeAgent!;
    }
    _store = DDStore(desc: "全局Store开始构建");
    _storeAgent = DDStoreAgent(store: _store);
    return _storeAgent!;
  }
}
